﻿using System;
using System.Linq;
using Extreme.SPFramework.DomainModel;

namespace Extreme.SPFramework.Test.Entities
{
    /// <summary>
    /// Test insurer entity
    /// </summary>
    public partial class Insurer : LinqEntityBase
    {
        public override Guid? UniqueId
        {
            get { return Id; }
            set { Id = value.GetValueOrDefault(); }
        }

        public override void Detach()
        {
            if (base.Attached.HasValue && !base.Attached.Value)
                return;
            base.Detach();

            this._Cases = Detach(this._Cases, attach_Cases, detach_Cases);
        }

        public override void Attach(System.Data.Linq.DataContext context)
        {
            if (base.Attached.HasValue && base.Attached.Value)
                return;
            base.Attach(context);

            if (this.Cases != null && this.Cases.HasLoadedOrAssignedValues)
                this.Cases.ToList().ForEach(c => c.Attach(context));
        }
    }
}
